#include "monitor.h"
#include <conio.h>
#include "convert_kbd.h"

unsigned shift_state = 0;
unsigned escaped=0;

void KeyboardISR()
{
    unsigned new_scan_code = inb(0x60);
    if (escaped) new_scan_code += 256;
    switch(new_scan_code) {
    case 0x2a: shift_state = 1; break;
    case 0xaa: shift_state = 0; break;
    case 0xe0: escaped = 1; break;
    default:
       if (new_scan_code & 0x80) {
         char new_char;
         convert_key(new_scan_code) >> new_char;
         monitor_write(new_char);          
       } else {
         char new_char; 
         convert_key(new_scan_code) >> new_char;
         monitor_write(new_char);
       }
   break;

   outb(0x20,0x20);
 }
}  
